package aynu.hd.Config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
@Service
public class SendeMail {
    @Autowired
    private JavaMailSender javaMailSender;

    private static final String SENDER = "2899092586@qq.com";

    public void sendMail(String email, int verificationCode) throws Exception{
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(SENDER);
        message.setTo(email);
        message.setSubject("天宇酒店");
        message.setText("尊敬的用户，您好。您的验证码为："+String.valueOf(verificationCode)+"，请妥善保管。");
        try {
            javaMailSender.send(message);
        } catch (Exception e) {
            e.getStackTrace();
        }
    }
}
